package com.patterns.composite.corpTree;

import java.util.ArrayList;

/**
 * @Creation_time 2017/7/17
 * @Theme 场景类
 * @Autor Xiao Yiyun
 */
public class Client {
    //遍历树
    public static String getTreeInfo(Branch branch) {
        ArrayList<Corp> subordinateList = branch.getSubordinateList();
        String info = null;
        for (Corp s : subordinateList) {
            if (s instanceof Leaf) {
                info = info + s.getInfo() + "\n";
            } else {
                info = info + s.getInfo() + "\n" + getTreeInfo((Branch)s);
            }
        }
        return info;
    }
}
